package com.geek.bams.entity;

import com.geek.bams.exception.BalanceNotEnoughException;

import java.io.Serializable;

public class SavingAccount extends  Account implements Serializable {
        private static final long serialVersionUID = 1L;

        public SavingAccount() {
        }

        public SavingAccount(Long id, String name, String password, String personId, String email, double balance) {
            super(id, name, password, personId, email, balance);
        }

        /**
         * 取款方法
         * @param money  取钱
         * @return  账户本身
         */
        public Account withdraw(double money) throws BalanceNotEnoughException {
            if(this.getBalance()>=money){
                this.setBalance(this.getBalance() - money);
                return this;
            }
            throw new BalanceNotEnoughException("您的账户余额不足！");

        }


    }
